import App from './App'
import { vDebounce } from './utils/directives';
import {i18n} from "@/locale/index.js";
import { createPinia } from 'pinia'
const pinia = createPinia();
// #ifndef VUE3
import Vue from 'vue'
import './uni.promisify.adaptor'
Vue.config.productionTip = false
App.mpType = 'app'
const app = new Vue({
  ...App
})
app.$mount()
// #endif

// #ifdef VUE3
import { createSSRApp } from 'vue'
if(uni.getStorageSync('__LAN__')){
	uni.$lang = uni.getStorageSync('__LAN__')
}else{
	uni.$lang = 'zh-Hans'
	uni.setLocale('zh-Hans')
	i18n.locale = 'zh-Hans'
	uni.setStorageSync('__LAN__','zh-Hans')
	// #ifdef H5
	window.location.reload()
	// #endif
}

export function createApp() {
  const app = createSSRApp(App)
  app.use(i18n)
  app.use(pinia);
  // 注册全局防抖指令
  app.directive('debounce', vDebounce);
  return {
    app
  }
}
// #endif